package demo;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Administrator
 * Date: 2023-07-02
 * Time: 14:17
 */
abstract class Animals{
    private String name;
    private int age;

    public Animals(String name,int age){
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public abstract void eat();
}

class Dog extends Animals{
    public Dog(String name,int age){
        super(name,age);
    }

    @Override
    public  void eat() {
        System.out.println(getName()+"吃狗粮");
    }
}

class Cat extends Animals{
    public Cat(String name, int age) {
        super(name, age);
    }
    @Override
    public void eat(){
        System.out.println(getName()+"吃猫粮");
    }
}
public class Test {
    public static void mals(Animals animals){
        animals.eat();
    }
    public static void main(String[] args) {
        mals(new Dog("小狗",2));
        mals(new Cat("小猫",2));
    }
}
